import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        long[] sum = new long[q];
        for(int j = 0; j < q; j++) {
            int x = in.nextInt();
            int y = in.nextInt();
            for(int k = x-1; k < y; k++) {
                sum[j] += a[k];
            }
        }
        for(long s:sum) {
            System.out.println(s);
        }
    }
}